<template>
  <div class="left-chart-2">
    <div class="lc2-header">7天发布情况</div>
    <div class="lc2-details">总共发布次数<span>{{total}}</span></div>
    <dv-capsule-chart class="lc2-chart" :config="config" />
    <dv-decoration-2 style="height:10px;" />
  </div>
</template>

<script>
import { getXyRelease } from "@/api/metrics"

export default {
  name: 'LeftChart2',
  data () {
    return {
      config: {
        data: [],
        colors: ['#eed810', '#0ae00e', '#c308ee', '#0b5fee', '#469f4b'],
        unit: '次',
        showValue: true
      },
      timer: {},
      total: ''
    }
  },
  mounted () {
    this.loadData()
    // eslint-disable-next-line no-unused-vars
    this.timer = setInterval(this.loadData, 1000 * 60 * 10)
  },
  beforeDestroy () {
    clearInterval(this.timer)
  },
  methods: {
    loadData: function () {
      getXyRelease().then(res => {
          // console.log(res.data)
          this.total = res.data.total
          // eslint-disable-next-line no-unused-vars
          const { config } = this
          this.config.data = res.data.data
          this.config = { ...this.config }// this.data = res
        })
        .catch(function (res) {
          console.log(res)
        })
    }
  }
}
</script>

<style lang="less">
.left-chart-2 {
  width: 100%;
  height: 30%;
  display: flex;
  flex-direction: column;

.lc2-header {
  text-align: center;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 20px;
  margin-bottom: 20px;
}
.lc1-header {
  text-align: center;
  height: 30px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 30px;
  margin-bottom: 15px;
}
.lc2-details {
  height: 40px;
  font-size: 16px;
  display: flex;
  align-items: center;
  text-indent: 20px;

span {
  color: #096dd9;
  font-weight: bold;
  font-size: 35px;
  margin-left: 20px;
}
}

.lc2-chart {
  flex: 2;
}
}
</style>
